package com.stations.controller;

import com.alibaba.fastjson.JSONObject;
import com.stations.common.constant.ControllerConstant;
import com.stations.common.web.base.BaseController;
import com.stations.domain.*;
import com.stations.domain.transmitterEntity.TransmitterResult;
import com.stations.service.TransmitterReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Describe: 发射机上报管理接口
 * Author: Ljy
 * CreateTime: 2019/10/23
 */
@RestController
@Api(tags = {"发射机上报"})
@RequestMapping(ControllerConstant.API_STATION_PREFIX + "v1")
public class TransmitterReportController extends BaseController {

    @Resource
    TransmitterReportService transmitterReportService;


    /**
     * Describe: 3.1.1.发射机基本信息上报
     * Param TTransmitter
     */
    @PostMapping("/transmitter/info")
    @ApiOperation(value = "")
    public TransmitterResult transmitterInfo(@RequestBody TTransmitter transmitter) {
        return transmitterReportService.transmitterInfo(transmitter);
    }

    /**
     * 3.1.2.发射机运行状态上报
     *
     * @param runningStatus
     */
    @PostMapping("/transmitter/status")
    public TransmitterResult transmitterStatus(@RequestBody RunningStatus runningStatus) {
        return transmitterReportService.transmitterStatus(runningStatus);
    }

    /**
     * 3.1.3.发射机故障告警上报
     *
     * @param exceptionList
     */
    @PostMapping("/transmitter/exception")
    public TransmitterResult transmitterException(@RequestBody ExceptionList exceptionList) {
        return transmitterReportService.transmitterException(exceptionList);
    }

    /**
     * 3.1.4.发射机故障解除上报
     *
     * @param exceptionList
     */
    @PostMapping("/transmitter/clearException")
    public TransmitterResult transmitterClearException(@RequestBody ExceptionList exceptionList) {
        return transmitterReportService.transmitterClearException(exceptionList);
    }

    /**
     * 3.1.5.发射机操作日志上报
     *
     * @param tTransmitterLog
     */
    @PostMapping("/transmitter/log")
    public TransmitterResult transmitterLog(@RequestBody TTransmitterLog tTransmitterLog) {
        return transmitterReportService.transmitterLog(tTransmitterLog);
    }

    /**
     * 3.1.6.通讯协议版本查询
     *
     * @param exceptionLog
     */
    @PostMapping("/protocol/version")
    public JSONObject protocolVersion(@RequestBody ExceptionLog exceptionLog) {
        return transmitterReportService.protocolVersion(exceptionLog);
    }

}
